package edu.sctu.zcy.month201506.day20150613.SerializableDemo;

import java.io.*;

/**
 * Created by wswk on 2015/6/13.
 */
public class SimpleSerializable {
    public static void main(String[] args) throws IOException {


        File file = new File("D:\\ZCY2\\zcy2.txt");


        ObjectOutputStream oout = new ObjectOutputStream(new FileOutputStream(file));

        Person person = new Person("周春艳",20,Gender.MALE);
        oout.writeObject(person);

        ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream(file));
        try {
            Person person1 = (Person) objectInputStream.readObject();

            objectInputStream.close();
            System.out.println(person1);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

    }
}
